var e = require("../../@babel/runtime/helpers/interopRequireDefault"), a = require("../../services/api.js"), n = e(require("../../utils/qrcode.js"));

Page({
    data: {
        info: {}
    },
    onLoad: function(e) {
        e.id ? this.getInfo(e.id) : wx.showModal({
            title: "提示",
            content: "无效的团购券",
            showCancel: !1,
            success: function() {
                wx.navigateBack();
            }
        });
    },
    createQrCode: function(e, a, t, o) {
        n.default.api.draw(e, a, t, o, this, this.canvasToTempImage);
    },
    canvasToTempImage: function(e) {
        var a = this;
        wx.canvasToTempFilePath({
            canvasId: e,
            success: function(e) {
                var n = e.tempFilePath;
                console.log(n), a.setData({
                    imagePath: n
                });
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    getInfo: function(e) {
        var n = this;
        (0, a.getOrderDetail)({
            order_sn: e
        }).then(function(e) {
            200 === e.data.code ? (n.setData({
                info: e.data.data
            }), n.createQrCode(e.data.data.id, "mycanvas", 150, 150)) : wx.showModal({
                title: "提示",
                content: e.data.message,
                showCancel: !1,
                success: function() {
                    wx.navigateBack();
                }
            });
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {}
});